<? 
    define('IN_SITE', true);
    include("common.php");  
    //include("/home/ypvnvn/public_html/yp/include/include.php");
    
    $ids = isset($_REQUEST['ids'])? $_REQUEST['ids'] : session_id();
    $lng = isset($_REQUEST['lang'])? $_REQUEST['lang'] : "vn";
    
    $langUrl=getOldUrl();
    $langvn=str_replace("supplier.php","vn/supplier.php",$langUrl);
    $langvn=str_replace("us","vn",$langvn);
    $langcn=str_replace("supplier.php","cn/supplier.php",$langUrl);
    $langcn=str_replace("us","cn",$langcn);
    
    $cid=isset($_GET["supplier"]) ? intval($_GET["supplier"]) :0;
    $catID=isset($_GET["catID"]) ? intval($_GET["catID"]) :0;
    $mode=isset($_GET["mode"]) ? htmlspecialchars($_GET["mode"]) : '';
    $ses_pro=$_SESSION["ses_pro"];
    $ses_pros=$_SESSION["ses_pros"];
    
    $sql1="select * from vb_memberprofile where memID=".$cid;
    if(!$result1=$db->sql_query($sql1)){
      message_die("Couldn't run the sql query!!!","",__LINE__,__FILE__,$sql1);
    }
    $p_count=$db->sql_numrows($result1);
    $p_data=$db->sql_fetchrowset($result1);

    //tri:Show About us tag
    $sql2="select * from vb_companyprofile where memID=".$cid;
    if(!$result2=$db->sql_query($sql2)){
      message_die("Couldn't run the sql query!!!","",__LINE__,__FILE__,$sql2);
    }
    $a_count=$db->sql_numrows($result2);
    $a_data=$db->sql_fetchrowset($result2);
    
    for($i=0;$i<$a_count;$i++){
        if (empty($a_data[$i]['aboutInfo']))
            $cabout=0;
        else
            $cabout=1;
    }
    
    //tri:Show Products tag{
    $sql="select * from vb_products where proActive=1 and memID=".$cid ;
    if ( !$result = $db->sql_query($sql) ) {
        message_die("Couldn't run the sql query!!!", __LINE__, __FILE__, $sql);
    }
    $total     = mysql_num_rows($result);
    if($total < 1){
       $tagPro = 0 ;
    }else{
       $tagPro = 1 ;
    }
    //}end show products

    //tri:Show selling Leads tag{
    $sql="select proID,ProductName,Keywords from vb_products where proActive=1 and memID=".$cid;
    
    if(!$result=$db->sql_query($sql)){
      message_die("Couldn't run the sql query!!!","",__LINE__,__FILE__,$sql);
    }
    $pro_count=$db->sql_numrows($result);
    $pro_data=$db->sql_fetchrowset($result);    
    if($catID){
        for($i=0;$i<$pro_count;$i++){
            if($pro_data[$i]["proID"]==$catID){
                $keyw=$pro_data[$i]["Keywords"];
                break;
            }
         }
    }
    
     $cSell=0;
    $sql= "select datepost,Effective,lID from vb_sell_lead where  active=1 and memID=".$cid;
    
    if(!$result=$db->sql_query($sql)){
      message_die("Couldn't run the sql query!!!","",__LINE__,__FILE__,$sql);
    }
    $sqlCommon.=' (lID=-1' ;
    $sel_count=$db->sql_numrows($result);
    $sel_data=$db->sql_fetchrowset($result);    
        for($i=0;$i<$sel_count;$i++){
             $expridate=getExpried($sel_data[$i]["Effective"],$sel_data[$i]["datepost"]);     
            
             if(date($expridate)>date('Y-m-d',time())){
                 $cSell=$cSell+1;
                $sqlCommon.=' or lID='.$sel_data[$i]['lID'] ; 
             }
         }

    $expir=$db->getRecord("select expired from vb_member where memID=".$cid);
    if($expir){
        redirect('index.php');
    }
    //}end selling Leads
function showlang(){
        global $template,$db,$langcn,$langvn ;
        $cid=isset($_GET["supplier"]) ? intval($_GET["supplier"]) :0;
        $sql ="select CompanyName,CompanyName_vn,CompanyName_cn from vb_memberprofile where memID=".$cid ;

        if(!$result1=$db->sql_query($sql)){
          message_die("Couldn't run the sql query!!!","",__LINE__,__FILE__,$sql1);
        }
        $p_data=$db->sql_fetchrow($result1);
        if(empty($p_data['CompanyName_vn']) or ($p_data['CompanyName_vn']=="NULL")){
    echo '
<a id="t1" style="cursor:pointer" onClick="setActiveStyleSheet(\'style1\',true); return false; "><img src="images/back.gif"></a>
<a id="t2" style="cursor:pointer" onClick="setActiveStyleSheet(\'style2\',true); return false;"><img src="images/red.gif"></a>
<a id="t3" style="cursor:pointer" onClick="setActiveStyleSheet(\'style3\',true); return false;"><img src="images/green.gif"></a>
<a id="t4" style="cursor:pointer" onClick="setActiveStyleSheet(\'style4\',true); return false;"><img src="images/prink.gif"></a>&nbsp;&nbsp;<a href="'.$langcn.'" class="style"> Chinese</a>' ;
        }elseif(empty($p_data['CompanyName_cn']) or ($p_data['CompanyName_cn']=="NULL")){
    echo '
<a id="t1" style="cursor:pointer" onClick="setActiveStyleSheet(\'style1\',true); return false; "><img src="images/back.gif"></a>
<a id="t2" style="cursor:pointer" onClick="setActiveStyleSheet(\'style2\',true); return false;"><img src="images/red.gif"></a>
<a id="t3" style="cursor:pointer" onClick="setActiveStyleSheet(\'style3\',true); return false;"><img src="images/green.gif"></a>
<a id="t4" style="cursor:pointer" onClick="setActiveStyleSheet(\'style4\',true); return false;"><img src="images/prink.gif"></a>&nbsp;&nbsp;<a href="'.$langvn.'" class="style"> Vietnamese </a>' ;
        }else{
    echo '
<a id="t1" style="cursor:pointer" onClick="setActiveStyleSheet(\'style1\',true); return false; "><img src="images/back.gif"></a>
<a id="t2" style="cursor:pointer" onClick="setActiveStyleSheet(\'style2\',true); return false;"><img src="images/red.gif"></a>
<a id="t3" style="cursor:pointer" onClick="setActiveStyleSheet(\'style3\',true); return false;"><img src="images/green.gif"></a>
<a id="t4" style="cursor:pointer" onClick="setActiveStyleSheet(\'style4\',true); return false;"><img src="images/prink.gif"></a>&nbsp;&nbsp;<a href="'.$langvn.'" class="style"> Vietnamese </a> | <a href="'.$langcn.'" class="style"> Chinese</a>' ;
        }        
    return ;
}
?>
<?
    //tri:    Hiển thị background cho top
    $sql= "select * from vb_style where memID=".$cid;
    if(!$result=$db->sql_query($sql)){
      message_die("Couldn't run the sql query!!!","",__LINE__,__FILE__,$sql);
    }
    $sty_count=$db->sql_numrows($result);
    $sty_data=$db->sql_fetchrow($result);
    if($sty_count){
        $style = explode(",",$sty_data['topBg']) ;
        $dfset = $sty_data['setstyle'] ;
    }else{
        $style = explode(",","head.gif,redhead.gif,greenhead.gif,prinkhead.gif") ;
        $dfset = $sty_data['setstyle'] ;
    }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META content="Find business listings in Vietnam with YellowPages.vn. Search by company's name, type of company, category, products &amp; services, phone, fax, etc." name=description>
<META content="business directory, Vietnam, yellow pages, yellow page, directory, portal, regional, phonebook, business guides, commercial guides, consumer guides, industrial guides, company guides, product guides, services guides, tour guide, company listings, product listings, services listings, businesses information, companies information, products searches, services searches, classified, company classifieds, products classifieds, services classifieds, company searches, classified ads, classified advertisements,ecommerce" name=keywords>
<META content="Business Yellow Pages" name=keyphrase>
<META content="Vietnam Yellow Pages Joint Stock Company" name=author>
<META content=index,follow name=robots>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>

<LINK href="<?=$site_base_href?>/images/style.css" type=text/css rel=stylesheet>
<LINK href="<?=$site_base_href?>/images/myStyle.css" type=text/css rel=stylesheet>
<LINK href="<?=$site_base_href?>/images/link.css" type=text/css rel=stylesheet>
<link href="images/style_green.css" type="text/css" rel=stylesheet>
<?php 
switch ($dfset){
    case "style1" : 
        echo '<link href="images/style_skyblue.css" rel="stylesheet" type="text/css"/>' ;
        break;
    case "style2" : 
        echo '<link href="images/style_orange.css" rel="stylesheet" type="text/css"/>' ;
        break;
    case "style4" : 
        echo '<link href="images/style_prink.css" rel="stylesheet" type="text/css"/>' ;
        break;
    default :
        echo '<link href="images/style_green.css" rel="stylesheet" type="text/css"/>' ;
        break;
}
?>
<link rel="alternate stylesheet" type="text/css" href="images/style_skyblue.css" title="style1" />
<link rel="alternate stylesheet" type="text/css" href="images/style_orange.css" title="style2" />
<link rel="alternate stylesheet" type="text/css" href="images/style_green.css" title="style3" />
<link rel="alternate stylesheet" type="text/css" href="images/style_prink.css" title="style4" />

<link rel="shortcut icon" href="ypg.ico" type="image/x-icon" />
<link rel="icon" href="ypg.ico" type="image/x-icon">
<style type="text/css">
/********** Use Background Top ******************/
    #tool {
        padding: 0px;
        margin: 0px;
        height: 90px;
        border: 1px solid #d8dbdf;
        border-top: 0;
    }
    .sky{background: url(background/<?=$style[0]?>) top right no-repeat;    }
    .orange{background: url(background/<?=$style[1]?>) top right no-repeat; }
    .green{    background: url(background/<?=$style[2]?>) top right no-repeat; }
    .prink{    background: url(background/<?=$style[3]?>) top right no-repeat;    }
/********** Text ******************/
    .style {font-size: 12px; color:#B3B3B3; font-family:Arial, Helvetica, sans-serif; text-decoration : none;}
    .borblack {    BORDER-RIGHT: #333333 1px solid; BORDER-TOP: #333333 1px solid; BORDER-LEFT: #333333 1px solid; BORDER-BOTTOM: #333333 1px solid;}
    .head{ color:#FFFFFF;font-family:Arial, Helvetica, sans-serif;font-size:12px; text-decoration:none}
    .head:hover{ color:#B3B3B3;font-family:Arial, Helvetica, sans-serif;font-size:12px; text-decoration:none}
    .bottom{ color:#FFFFFF;font-family:Arial, Helvetica, sans-serif;font-size:11px;}
    .pro{font-size:12px; color:#FFFFFF; font-family:Arial, Helvetica, sans-serif}
    .txt_searchTop {PADDING-LEFT: 5px; FONT-SIZE: 10px; WIDTH: 280px; FONT-FAMILY: Arial, Helvetica, sans-serif; HEIGHT: 18px
    }
    .ca{font-family:Arial, Helvetica, sans-serif;font-size:12px;text-decoration:none;color:#3366CC}
    .ca:hover{font-family:Arial, Helvetica, sans-serif;font-size:12px;text-decoration:none;color:#FF9900}
</style>
<SCRIPT language=javascript src="js/jsfunc.js"></SCRIPT>
<script type="text/javascript" src="js/styleswitcher.js"></script>
<script language="javascript" type="text/javascript">
    <!--
    function setStyle(title){
        switch (title){
            case "style1" : 
                setClass('tool','sky') ;    
                break;
            case "style2" : 
                setClass('tool','orange') ;    
                break;
            case "style3" : 
                setClass('tool','green') ;    
                break;
            case "style4" : 
                setClass('tool','prink') ;
                break;
        }
    }
    function setClass(tagID,Class){
        var bg,myTagName,myClass ;
        TagName = document.getElementById(tagID);
        myClass = TagName.className = Class ;
    }
//-->
</script>
</HEAD>
<BODY topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<table width=779 align="center" cellPadding=0 cellSpacing=0 class="borblack">
  <tr>
    <td><table width="100%" height="90" cellSpacing="0" class="tab" id="tool">
        <TR>
          <TD><? include "name.php" ?></TD>
        </TR>
      </table>
      <TABLE  height=30 cellSpacing=0 cellPadding=0 width=100%  border=0 align="center">
        <TR >
          <TD width="8%" id="brand"><div align="center"><a href="supplier.php?supplier=<?=$cid?>&ids=<?=$ids?>&lang=us" class="head"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></a></div></TD>
          <td width="1"></td>
          <td width="11%" id="brand" style="display: <?= ($cabout > 0) ? 'display' : 'none'?>"><div align="center"><a href="supplier.php?supplier=<?=$cid?>&mode=view&ids=<?=$ids?>&lang=us" class="head"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;About Us&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></a></div></td>
          <td width="1"></td>
          <TD width="10%" id="brand" style="display: <?= ($tagPro > 0) ? 'display' : 'none'?>"><div align="center"><a href="supplier.php?supplier=<?=$cid?>&act=products&mode=main&ids=<?=$ids?>&lang=us" class="head"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Product&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></a></div></TD>
          <td width="1"></td>
          <TD width="10%" id="brand"><div align="center"><a href="supplier.php?act=comprofile&supplier=<?=$cid?>&ids=<?=$ids?>&lang=us" class="head"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Profile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></a> </div></TD>
          <td width="1"></td>
          <td width="15%" id="brand" style="display: <?= $cSell>0 ? 'display' : 'none'?>"><div align="center"><a href="<?= $cSell>0 ? 'supplier.php?ids='.$ids.'&lang=us&act=vleads&supplier='.$cid : '#' ?>" class="head"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selling Leads&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></a></div></td>
          <TD width="10%" id="brand"><div align="center">
              <? 
     if($ses_pro || $ses_pros){
        $ses=count($ses_pro)+count($ses_pros);
        echo '<a href="'.$site_base_href.'/index.php?ids='.$ids.'&lang=us&/contact/addToCard"   class="head" target="_blank"><strong>Basket('.$ses.')</strong></a>';
      }else{
          echo '<a href="'.$site_base_href.'/index.php?ids='.$ids.'&lang=us&/contact/addToCard "   class="head" target="_blank"><strong>Basket</strong></a>';
      } 
    ?>
            </div></TD>
          <td width="1" ><div align="center"></div></td>
          <TD width="100%" class="head" id="brand">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
        </TR>
      </TABLE>
  <tr>
    <TD align="center" vAlign=top bgcolor="#FFFFFF" ><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <TD  height="26"  class="lMenu" valign="middle" style="padding-left:10px ">&nbsp;</TD>
          <TD align="right" valign="middle" style="padding-right:18px;" class="style"><?php showlang()?>
            <span style="display:none"> <a id="t1" style="cursor:pointer" onClick="setActiveStyleSheet('style1',true); return false; "><img src="images/back.gif"></a> <a id="t2" style="cursor:pointer" onClick="setActiveStyleSheet('style2',true); return false;"><img src="images/red.gif"></a> <a id="t3" style="cursor:pointer" onClick="setActiveStyleSheet('style3',true); return false;"><img src="images/green.gif"></a> <a id="t4" style="cursor:pointer" onClick="setActiveStyleSheet('style4',true); return false;"><img src="images/prink.gif"></a>&nbsp;&nbsp;<a href="<?=$langvn?>" class="style"> Vietnamese </a> | <a href="<?=$langcn?>" class="style"> Chinese</a></span> </TD>
        </tr>
      </table>
      <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
        <tr>
          <td  valign="top" class="text-default"><?php    unset($pro_data);
    $act = isset($_GET['act']) ? htmlspecialchars($_GET['act']) :'';    
        switch($act){
            case "comprofile":
                include "memInfo.php";    
                    break;
            case "memcontacts":
                include"memcontacts.php";
                break;
            case "products":
                include "memproducts.php";    
                break;                
            case "vleads":
                include "memSellLeads.php";    
                break;              
            default:        
                include "aboutus.php";    
                break;        
        }
         $db->sql_close();
?>
          </td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td height="50" class="bottom" id="brand" ><table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td style="padding-left:8px;"><? 
     for($i=0;$i<$p_count;$i++){     
        echo "<table  cellPadding=0 cellSpacing=0 class=bottom width=779 ><tr><td align=left style='padding-left:10px' class=bottom>".$p_data[$i]['Address'].", ".$p_data[$i]['City']." <td></tr>";
        echo "<tr><td height=5 ></td></tr>";
            if( $p_data[$i]["FaxNumber"]==''){
                echo "<tr><td align=left style='padding-left:10px '>Phone: (".number_format($p_data[$i]['contrycode']).")(".number_format($p_data[$i]['areacode']).") ".$p_data[$i]['BusinessPhone']."</td></tr></table> ";
            }else{
                echo "<tr><td align=left style='padding-left:10px '>Phone: (".number_format($p_data[$i]['contrycode'])."-".number_format($p_data[$i]['areacode']).") ".$p_data[$i]['BusinessPhone']."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fax: (".number_format($p_data[$i]["faxcontrycode"])."-".number_format($p_data[$i]["faxareacode"]).") ".$p_data[$i]["FaxNumber"]."</td></tr></table> ";
            }
    };
    ?></td>
        </tr>
      </table></td>
  </tr>
</table>
<table width=779 align="center" cellPadding=0 cellSpacing=0>
  <tr>
    <td align="right" style="color:#B3B3B3;font-family:Arial, Helvetica, sans-serif;font-size:9px " >Copyright Â© 2007 Yellow Pages JSC. All rights reserved. </td>
  </tr>
</table>
</body>